package fallbackfactory;

import cn.kz.hrm.feignclient.SystemFeignClient;
import cn.kz.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class SystemFeignClientFallbackFactory implements FallbackFactory<SystemFeignClient>{

    private Logger logger = LoggerFactory.getLogger(SystemFeignClientFallbackFactory.class);

    public SystemFeignClient create(Throwable throwable) {
        return new SystemFeignClient(){
            @Override
            public AjaxResult getUserLoginPermissonsToString(Long id) {
                logger.error("获取数据失败！降级了呀！");
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("获取数据失败！降级了呀！");
            }
        };
    }
}
